package common;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.io.Serializable;

import client.Client;

/**
 * 
 * @author Debora Bolli
 *
 */
public class Hexagramm implements Serializable{
	
	public int number;
	public String code;
	public int nuclear_number;
	public int inverse_number;
	public int reverse_number;
	public int fuxi_number;
	
	public String user_notes = "";
	public String user_line1 = "";
	public String user_line2 = "";
	public String user_line3 = "";
	public String user_line4 = "";
	public String user_line5 = "";
	public String user_line6 = "";


	public String getName(){
		return Client.getText("hexa_" + Integer.toString(number) + "_name");
	}
	
	public String getComment(){
		return Client.getText("hexa_" + Integer.toString(number) + "_comment");
	}
	
	public String getJudgement(){
		return Client.getText("hexa_" + Integer.toString(number) + "_judgement");
	}
	
	public String getImage(){
		return Client.getText("hexa_" + Integer.toString(number) + "_image");
	}
	
	public String getLine1(){
		System.out.println("Lang4: "+Client.getInstance().getLanguage());
		System.out.println(Client.getText("Abbrechen"));
		return Client.getText("hexa_" + Integer.toString(number) + "_textline1");
	}
	
	public String getLine2(){
		return Client.getText("hexa_" + Integer.toString(number) + "_textline2");
	}
	
	public String getLine3(){
		return Client.getText("hexa_" + Integer.toString(number) + "_textline3");
	}
	
	public String getLine4(){
		return Client.getText("hexa_" + Integer.toString(number) + "_textline4");
	}
	
	public String getLine5(){
		return Client.getText("hexa_" + Integer.toString(number) + "_textline5");
	}
	
	public String getLine6(){
		return Client.getText("hexa_" + Integer.toString(number) + "_textline6");
	}
	
	public String getUserNotes(){
		return user_notes;
	}
	
	public String getUserLine1(){
		return user_line1;
	}
	
	public String getUserLine2(){
		return user_line2;
	}
	
	public String getUserLine3(){
		return user_line3;
	}
	
	public String getUserLine4(){
		return user_line4;
	}
	
	public String getUserLine5(){
		return user_line5;
	}
	
	public String getUserLine6(){
		return user_line6;
	}
	
	public void draw(Graphics g) {
//		int[] werte = {
//				7,
//				6,
//				8,
//				6,
//				9,
//				7
//		};
//		
		this.draw(g, code, 11, 50, 10);		
	}

	public void draw(Graphics g, String code) {
		this.draw(g, code, 11, 50, 10);		
	}

	public void draw(Graphics g, String code, int x, int y, int size) {
		System.out.println("Draw: "+code + "("+Integer.toString(code.length()) + ")");
		for (int i = code.length() - 1; i >= 0; i--) {
		
			Font font = new Font("Arial", Font.PLAIN, 2*size);
			g.setFont(font);
System.out.println("Check for: " + Integer.toString(Integer.valueOf(code.charAt(i)-48)));
			switch (Integer.valueOf(code.charAt(i)-48)) {
			case 6:
				g.setColor(Color.BLACK);
				g.fillRect(x, y, 9 * size, 2 * size);
				g.fillRect(x + 11 * size, y, 9 * size, 2 * size);
				break;
			case 1:
			case 7:
				g.setColor(Color.BLACK);
				g.fillRect(x, y, 20 * size, 2 * size);
				break;
			case 0:
			case 8:
				g.setColor(Color.BLACK);
				g.fillRect(x, y, 9 * size, 2 * size);
				g.fillRect(x + 11 * size, y, 9 * size, 2 * size);
				break;
			case 9:
				g.setColor(Color.BLACK);
				g.fillRect(x, y, 20 * size, 2 * size);
				break;
			}
			y += 4 * size;
		}
	}

}
